package 游游的you;

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int q = in.nextInt();
        while (q-- > 0) {
            int y = in.nextInt();
            int o = in.nextInt();
            int u = in.nextInt();
            int res = Math.min(y, Math.min(o, u));
            res = Math.max(o - res - 1, 0) + 2 * res;
            System.out.println(res);
        }
    }
}
